//
//  ClassifyRegViewController.m
//  安好
//
//  Created by lianchuang on 14-12-9.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "ClassifyRegViewController.h"
#import "RegistrationCell.h"
#import "RegHospitalListViewController.h"
#import "WikiDepartmentViewController.h"
#import "RegDoctorListViewController.h"
#import "IllnessViewController.h"

#define RGB(r, g, b)    [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f]

#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

@interface ClassifyRegViewController ()<UITableViewDataSource,UITableViewDelegate>
//快速挂号tableView
@property (strong, nonatomic) UITableView *tableView;

@property(nonatomic,strong)NSArray * dataArray ;


@end

@implementation ClassifyRegViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
    [self makeNavBar];
    [self makeTableView];
    
}
#pragma mark - 导航条设置
-(void)makeNavBar
{
    self.navigationItem.title = @"分类挂号";
    //左按钮--返回
    UIBarButtonItem *backBtnImg = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backClicked)];
    [backBtnImg setTintColor:[UIColor whiteColor]];
    self.navigationItem.leftBarButtonItem = backBtnImg;
}
//返回
-(void)backClicked
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)loadData
{
    self.dataArray = @[@"按医院",@"按科室",@"按专家",@"按病症"];

}
#pragma mark - 创建tableView
-(void)makeTableView
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-iOS7TopMargin) style:UITableViewStyleGrouped];
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //隐藏横向和竖向的滑条
    self.tableView.showsHorizontalScrollIndicator = NO;
    self.tableView.showsVerticalScrollIndicator = NO;
//    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView setSeparatorColor:RGB(221, 221, 221)];

}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (iPhone6Plus) {
        return 53;
    }else{
        return 44;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    RegistrationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
    
    if (cell == nil) {
        if (iPhone6Plus) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"RegistrationCell" owner:self options:nil] lastObject];
        }else{
            cell = [[[NSBundle mainBundle] loadNibNamed:@"RegistrationCell" owner:self options:nil] firstObject];
        }
    }
    cell.registrationLable.text =self.dataArray[indexPath.row];
    UIImage * jumpImg = [UIImage imageNamed:@"公用_跳转.png"];
    [cell.accessoryTypeImgView setImage:jumpImg];
    cell.accessoryTypeImgView.frame = CGRectMake(kScreenWidth-(15+jumpImg.size.width), (cell.contentView.height-jumpImg.size.height)/2.0, jumpImg.size.width,jumpImg.size.height);
    if (iPhone6Plus) {
        cell.accessoryTypeImgView.right = kScreenWidth - 20;
    }
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //按医院
    if (indexPath.row == 0) {
        RegHospitalListViewController * hospitasl = [[RegHospitalListViewController alloc] init];
        hospitasl.parDic = @{@"provinceid":@"0",@"cityid":@"0",@"level":@"0"};
        [self.navigationController pushViewController:hospitasl animated:YES];
    }
    //按科室
    if (indexPath.row == 1) {
        WikiDepartmentViewController * desk = [[WikiDepartmentViewController alloc] init];
        desk.fromFlag = @"reg";
        [self.navigationController pushViewController:desk animated:YES];
        
    }
    //按专家
    if (indexPath.row == 2) {
        RegDoctorListViewController * doclist = [[RegDoctorListViewController alloc] init];
        [self.navigationController pushViewController:doclist animated:YES];
    }
    //按病症
    if (indexPath.row == 3) {
        IllnessViewController * Myill = [[IllnessViewController alloc] init];
        Myill.fromReg = @"挂号疾病";
        [self.navigationController pushViewController:Myill animated:YES];
        
    }
    

}

@end
